Add smart geocaching names to TomTom writer.
authorrobertl <robertl>
Sun, 20 Jan 2008 23:36:53 +0000 (23:36 +0000)
committerrobertl <robertl>
Sun, 20 Jan 2008 23:36:53 +0000 (23:36 +0000)
tomtom.c

index db894b782f1b488e3d5004c6f014c38cc094584e..070324784d3692941a362693fe665e4cd71ebcc7 100644 (file)
--- a/tomtom.c
+++ b/tomtom.c
@@ -231,10 +231,24 @@ write_blocks( FILE *f, struct blockheader *blocks ) {
        if ( !blocks->ch1 && !blocks->ch2 ) {
                for ( i = 0; i < blocks->count; i++ ) {
                        write_char( f, 2 );
-                       write_long( f, strlen( blocks->start[i].wpt->description ) + 14 );
+            char desc_field [256];
+            if (global_opts.smart_names && 
+                       blocks->start[i].wpt->gc_data.diff && 
+                       blocks->start[i].wpt->gc_data.terr) {
+                snprintf(desc_field,256,"%s(t%ud%u)%s(type%dcont%d)",blocks->start[i].wpt->description,
+                blocks->start[i].wpt->gc_data.terr/10,
+                blocks->start[i].wpt->gc_data.diff/10,
+                blocks->start[i].wpt->shortname,
+                (int) blocks->start[i].wpt->gc_data.type,
+                (int) blocks->start[i].wpt->gc_data.container);
+                //Unfortunately enums mean we get numbers for cache type and container.
+            } else {
+                strcpy(desc_field,blocks->start[i].wpt->description);
+            }
+                       write_long( f, strlen( desc_field ) + 14 );
                        write_float_as_long( f, blocks->start[i].wpt->longitude*100000);
                        write_float_as_long( f, blocks->start[i].wpt->latitude*100000);
-                       write_string( f, blocks->start[i].wpt->description);
+                       write_string( f, desc_field);
                }
        }
 }